<cfcomponent name="issuesService" output="false">

	<cffunction name="init" access="public" output="false" returntype="trac_fu.model.issues.issuesService">
		<cfargument name="issuesDAO" type="trac_fu.model.issues.issuesDAO" required="true" />
		<cfargument name="issuesGateway" type="trac_fu.model.issues.issuesGateway" required="true" />

		<cfset variables.issuesDAO = arguments.issuesDAO />
		<cfset variables.issuesGateway = arguments.issuesGateway />

		<cfreturn this/>
	</cffunction>

	<cffunction name="getissues" access="public" output="false" returntype="issues">
		<cfargument name="id" type="string" required="true" />
		
		<cfset var issues = createObject("component","trac_fu.model.issues.issues").init(argumentCollection=arguments) />
		<cfreturn variables.issuesDAO.read(issues) />
	</cffunction>

	<cffunction name="getissuess" access="public" output="false" returntype="query">
		<cfargument name="id" type="string" required="false" />
		<cfargument name="projectidfk" type="string" required="false" />
		<cfargument name="created" type="date" required="false" />
		<cfargument name="updated" type="date" required="false" />
		<cfargument name="name" type="string" required="false" />
		<cfargument name="useridfk" type="string" required="false" />
		<cfargument name="creatoridfk" type="string" required="false" />
		<cfargument name="description" type="string" required="false" />
		<cfargument name="history" type="string" required="false" />
		<cfargument name="isbug" type="boolean" required="false" />
		<cfargument name="locusidfk" type="string" required="false" />
		<cfargument name="severityidfk" type="string" required="false" />
		<cfargument name="statusidfk" type="string" required="false" />
		<cfargument name="relatedurl" type="string" required="false" />
		<cfargument name="attachment" type="string" required="false" />
		<cfargument name="publicid" type="numeric" required="false" />
		<cfargument name="duedate" type="date" required="false" />
		
		<cfreturn variables.issuesGateway.getByAttributes(argumentCollection=arguments) />
	</cffunction>

	<cffunction name="saveissues" access="public" output="false" returntype="boolean">
		<cfargument name="id" type="string" required="true" />
		<cfargument name="projectidfk" type="string" required="true" />
		<cfargument name="created" type="date" required="true" />
		<cfargument name="updated" type="date" required="true" />
		<cfargument name="name" type="string" required="true" />
		<cfargument name="useridfk" type="string" required="true" />
		<cfargument name="creatoridfk" type="string" required="false" />
		<cfargument name="description" type="string" required="true" />
		<cfargument name="history" type="string" required="true" />
		<cfargument name="isbug" type="boolean" required="true" />
		<cfargument name="locusidfk" type="string" required="true" />
		<cfargument name="severityidfk" type="string" required="true" />
		<cfargument name="statusidfk" type="string" required="true" />
		<cfargument name="relatedurl" type="string" required="false" />
		<cfargument name="attachment" type="string" required="false" />
		<cfargument name="publicid" type="numeric" required="false" />
		<cfargument name="duedate" type="date" required="false" />
		
		
		<cfset var issues = getissues(arguments.id) />
		<cfset issues.setid(arguments.id) />
		<cfset issues.setprojectidfk(arguments.projectidfk) />
		<cfset issues.setcreated(arguments.created) />
		<cfset issues.setupdated(arguments.updated) />
		<cfset issues.setname(arguments.name) />
		<cfset issues.setuseridfk(arguments.useridfk) />
		<cfif structKeyExists(arguments,"creatoridfk")>
			<cfset issues.setcreatoridfk(arguments.creatoridfk) />
		</cfif>
		<cfset issues.setdescription(arguments.description) />
		<cfset issues.sethistory(arguments.history) />
		<cfset issues.setisbug(arguments.isbug) />
		<cfset issues.setlocusidfk(arguments.locusidfk) />
		<cfset issues.setseverityidfk(arguments.severityidfk) />
		<cfset issues.setstatusidfk(arguments.statusidfk) />
		<cfif structKeyExists(arguments,"relatedurl")>
			<cfset issues.setrelatedurl(arguments.relatedurl) />
		</cfif>
		<cfif structKeyExists(arguments,"attachment")>
			<cfset issues.setattachment(arguments.attachment) />
		</cfif>
		<cfif structKeyExists(arguments,"publicid")>
			<cfset issues.setpublicid(arguments.publicid) />
		</cfif>
		<cfif structKeyExists(arguments,"duedate")>
			<cfset issues.setduedate(arguments.duedate) />
		</cfif>
		<cfreturn variables.issuesDAO.save(arguments.issues) />
	</cffunction>

	<cffunction name="deleteissues" access="public" output="false" returntype="boolean">
		<cfargument name="id" type="string" required="true" />
		
		<cfset var issues = createObject("component","trac_fu.model.issues.issues").init(argumentCollection=arguments) />
		<cfreturn variables.issuesDAO.delete(issues) />
	</cffunction>
</cfcomponent>